﻿package com.bizmlib.utils
{
	/**
	 * Extracts a function, setter or getter name from a provided stack trace. Stack trace can be retrieved using the Error's object 
	 * getStackTrace method. This function the name of the method in the first(actually in the second) line of the trace.
	 *
	 * @param	stackTrack	provided stack trace
	 * @return	extracted name of the method
	 */
	public function extractFunctionNameFromStackTrace(stackTrace:String):String
	{
		//var re:RegExp = /.*\/(get|set\s)?(\w*)\(.*/;
		var re:RegExp = /.*\W(\w+)\(.*/;
		var reResult:Array = re.exec(stackTrace);
		return reResult[1] || undefined;
	}
}